﻿using System.IO;
using Magellan.ProjectWizards.Manager.Helpers;

namespace Magellan.ProjectWizards.Manager.Commands
{
    public class UninstallTemplateCommand : ICommand
    {
        public bool Execute()
        {
            if (!VisualStudioHelper.EnsureVisualStudioIsNotRunning())
            {
                return false;
            }

            var common = VisualStudioHelper.GetCommon7Path();
            var windowsTemplates = Path.Combine(common, @"IDE\ProjectTemplates\CSharp\Windows");
            
            foreach (var locale in Directory.GetDirectories(windowsTemplates))
            {
                File.Delete(Path.Combine(locale, "Magellan.zip"));
            }

            return true;
        }
    }
}